
#include "Element.h"
#include "Entity.h"

namespace p2 {

Element::~Element()
{
}

void Element::updateTransform()
{
	_transform.setTranslation(_x);
	_transform.setAngle(_a);
	_transform.setScale(Vector2<real>::ONE);
	_worldMatrix = _transform.getMatrix() * _owner->getTransform().getMatrix();
	Vector4<real> wx4(Vector4<real>(_x) * _owner->getTransform().getMatrix());
	_worldPosition = Vector2<real>(wx4.X(), wx4.Y());
}

Matrix4<real> Element::getModelViewMatrix()
{
	Vector2<real> scale(_halfExtent * (real)2);
	Transform2<real> transform(_x, _a, scale);
	return transform.getMatrix() * _owner->getTransform().getMatrix();
}

inline Matrix4<real> Element::getFutureWorldMatrix(real64 dT)
{
	return _transform.getMatrix() * _owner->getFutureWorldTransform(dT).getMatrix();
}

}
